package cate.game.play.skill.passive.guild;

import cate.common.table.d.GDAttr;
import cate.common.table.d.GDSkill;
import cate.common.util.XT;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.passive.PassiveHandler;

import java.util.List;

/**
 * 出手时额外为生命值最低的1个单位恢复施法者攻击力50%的生命值和20%的暴伤减免，并附加【复苏】(受到伤害时恢复已损失生命7%的生命值，持续2回合)，每回合至多生效1次
 */
public class 妙手回春PH extends PassiveHandler {

	private List<Integer> buff;

	//buff=??
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		buff = args.getIntList("buff");
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		addBuff = false;
	}

	private boolean addBuff;

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if(XT.isBlank(buff)){
			return;
		}
		if (addBuff) {
			return;
		}
		Fighter target = TargetSelector.findOne(skill.owner, action.getTeamVs(), new TargetFilterParam().scopeSet(GDSkill.Scope.WE).smallAttrSet(GDAttr.V_HP_LEFT));
		if (target != null) {
			for (Integer integer : buff) {
				target.buff.tryAddByTid(action, skill.owner, integer);
			}
			addBuff = true;
		}
	}
}
